#include <bits/stdc++.h>
#define int long long
using namespace std;
inline void solve()
{
    int l, r;
    cin >> l >> r;
    if (l == 1)
    {
        cout << 0 << '\n';
        return;
    }
    int ans = 0;
    int buchang = r - l;

    if (l == r)
    {
        cout << "infty" << '\n';
        return;
    }
    int xian = (l - 1) % buchang;
    int nn = ((l - 1) - xian) / buchang + 1;

    ans = xian * nn + nn * (nn - 1) / 2 * buchang;
    cout << ans << '\n';
}
signed main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int T;
    cin >> T;
    while (T--)
    {
        solve();
    }
    return 0;
}
